#ifndef OESUPERMANAGERSQLDATABASE_H
#define OESUPERMANAGERSQLDATABASE_H

#include <QObject>
#include <QSqlDatabase>

class OESuperManagerSqlDatabase : public QObject
{
    Q_OBJECT
public:
    explicit OESuperManagerSqlDatabase(QObject *parent = 0);

    static int checkDB(void);

    static int registerDB(const QString& _dbFileName,
                   const QString& _sqlRes);
    /**
    * brief: 注册用户
    * return: 0 success , not 0 failed
    */
    static int registerUser(const QString& _user,
                     const QString& _pswd,
                     const QString& _name,
                     const QString& _issue1,
                     const QString& _answer1,
                     const QString& _issue2,
                     const QString& _answer2);

    static int getAccountInfo(const QString& _user,
                              QString& _username,
                              QString& _issue1,
                              QString& _issue2);

    static int checkAccountInfo(const QString& _user,
                                const QString& _issue1,
                                const QString& _answer1,
                                const QString& _issue2,
                                const QString& _answer2);


    /**
     *
    */
    static int modifyName(const QString& _user,
                          const QString& _pswd,
                          const QString& _newName);

    /**
     *
    */
    static int modifyPswd(const QString& _user,
                          const QString& _pswd,
                          const QString& _newPswd);


    static int openDB(const QString& _dbName, QSqlDatabase& _db);


    /**
    * brief: check super manager pswd
    * return: 0 success, not 0 failed
    */
    static int checkPswd(const QString &_user,
                  const QString& _pswd);


    static bool isExist();

    static QString dbPath(void);
signals:

public slots:
private:
    static QString dbFileName_;
};

#endif // OESUPERMANAGERSQLDATABASE_H
